package com.smartwebx.ha.dal.realtime.dao;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import com.smartwebx.ha.dal.config.OracleConfigInfo;
import com.smartwebx.ha.dal.inter.water.ISLMProcessDataOperatDao;
import com.smartwebx.ha.dal.realtime.sqlprovider.SoilProvider;
import com.smartwebx.ha.dal.usebean.DateValue;
import com.smartwebx.ha.dal.usebean.GisWater;

/**
 * 土壤墒情
 * @author zhangxi
 *
 */
public interface SoilMapper extends ISLMProcessDataOperatDao	 {
	String ST_SOIL_R = OracleConfigInfo.REALTIME_NAME + ".ST_SOIL_R";

	@SelectProvider(type = SoilProvider.class, method = "getAllStatMoistureSQL")
	public List<GisWater> getAllStatMoistureStcdFilter(
			@Param("datePoint") Date datePoint,
			@Param("selFieldName") String selSLMName);

	
	@SelectProvider(type = SoilProvider.class, method = "getPurenessSoilProcesssSQL")
	public List<DateValue> getPurenessSoilProcesss(@Param("stcd") String stcd,
			@Param("startDate") Date startDate, @Param("endDate") Date endDate,
			@Param("selSLMName") String selSLMName, @Param("exKey") String exKey);

	@SelectProvider(type = SoilProvider.class, method = "getSingleStatDayAvgProcessSQL")
	public List<DateValue> getSingleStatDayAvgProcess(
			@Param("stcd") String stcd, @Param("startDate") Date startDate,
			@Param("endDate") Date endDate, @Param("exKey") String exKey);

	@Select("SELECT TM,#{selSLMName} val FROM " + ST_SOIL_R
			+ " WHERE STCD = #{stcd} AND TM >= #{startDate} AND "
			+ "TM < #{endDate} AND to_char(TM,'HH24')=8 AND EXKEY = #{exKey}")
	public List<DateValue> getSingleStatDaySelProcess(
			@Param("stcd") String stcd, @Param("startDate") Date startDate,
			@Param("endDate") Date endDate,
			@Param("selSLMName") String selSLMName, @Param("exKey") String exKey);

	@SelectProvider(type = SoilProvider.class, method = "getStartHourBeforeAvgValSQL")
	public DateValue getStartHourBeforeAvgVal(@Param("stcd") String stcd,
			@Param("datePoint") Date startHour, @Param("exKey") String exKey);

	@Select("SELECT TM,#{selSLMName} val FROM " + ST_SOIL_R
			+ " WHERE STCD = #{stcd} AND TM < #{datePoint} AND "
			+ "EXKEY = #{exKey} ORDER BY TM DESC")
	public DateValue getStartHourBeforeSelVal(@Param("stcd") String stcd,
			@Param("datePoint") Date startHour,
			@Param("selSLMName") String selSLMName, @Param("exKey") String exKey);
}
